<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title> CSS 文字覆盖图像悬停效果 – 淡入透明
    </title>
</head>
<body>
<h2>淡入透明效果</h2>
<p>鼠标移动到图片上查看效果</p>

<div class="container">
    <img src="../img/pineapple.jpg" alt="Avatar" class="image">
    <div class="overlay">
        <div class="text">Hello World</div>
    </div>
</div>
<style>
    .container:hover .image{
        opacity: 0.5;
        transition: 1s;
    }
    .container{
        width: 300px;
        height: 300px;
        position: relative;

    }
    .overlay{
        height: 30px;
        width: 100%;
        background-color: green;
        position: absolute;
        left:0;
        bottom: 0
    }
    .text{
        color: white;
    }


</style>

</body>
</html>
